package com.ziyun.erp.modules.material.dao;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.ziyun.erp.modules.material.entity.MaterialEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 原料耗材库
 * 
 * @author guizhao
 * @email ...
 * @date 2018-07-31 14:03:39
 */
public interface MaterialDao extends BaseMapper<MaterialEntity> {


    void updateByMap(@Param("map") Map<String, Object> map, @Param("materialId") Integer materialId);

    List<MaterialEntity> queryMaterialsListPage(Pagination page, @Param("map") Map<String,Object> map);

    int getqueryCountByname(@Param("materialName") String materialName);


    List<MaterialEntity> getQueryListByname(@Param("params") Map<String,Object> params);

    int getqueryCount(@Param("categoryId") Integer categoryId);

    int getqueryCountBycategoryId();

    List<MaterialEntity> getQueryList(@Param("params") Map<String,Object> params);

    List<MaterialEntity> getQueryListBycategoryId(@Param("params") Map<String,Object> params);

    int getqueryCount2();

    List<MaterialEntity> getQueryList2(@Param("params") Map<String,Object> params);

    int getParentId(@Param("categoryId") Integer categoryId);

    @Select("select material_id as materialId from erp_material where material_code = #{materialCode}")
    String getMaterialId(@Param("materialCode") String materialCode);

    @Insert("insert into store_stock_material(stock_id,material_id,cost) values (#{stockId},#{materialId},#{cost}) ")
    int saveMaterialByStockId(@Param("stockId") Integer stockId,@Param("materialId") String materialId,@Param("cost") BigDecimal cost);

    @Select("select stock_id from erp_stock where institution = #{sellerId} and type = 1")
     Integer getStockId(@Param("sellerId") Integer sellerId);

}
